package cn.gd.controller.sealManagement;

import cn.gd.pojo.Department;
import cn.gd.pojo.Sealusage;
import cn.gd.service.sealManagement.sealManagementService;
import cn.gd.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wyh
 * @version 1.80
 */
@CrossOrigin
@RestController
@RequestMapping("/sealManagement")
public class sealManagementController {
    @Autowired
    private sealManagementService sealManagementService;

    @GetMapping("/queryDepartment/{realName}")
    private Result<List<Department>> queryDepartment(@PathVariable String realName){
        return Result.ok(sealManagementService.queryDepartment(realName));
    }

    @PostMapping("/addDepartment")
    private Result<Map<String, String>> addDepartment(@RequestBody Sealusage sealusage){
        System.out.println(sealusage.getUserID());
        int num = sealManagementService.addDepartment(sealusage);
        Map<String, String> map = new HashMap<>();
        if (num > 0) {
            map.put("result", "true");
        } else {
            map.put("result", "false");
        }
        return Result.ok(map);
    }


}
